﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace game
{
    public class EmitterPSystem : PointSpriteParticleSystem
    {

        public EmitterPSystem(Scene scene, Vector3 position)
            : base(scene, position)
        {
        }

        protected override void InitParameters()
        {
            textureName = "Textures\\8195-v8";
            effectName = "Effects\\RegularPSystem";
            effectTechName = "AdditiveBlendingSystem";

            Acceleration = -0.0f;
            maxParticles = 40;

            emitter = new ParticleEmitter(this, 15.0f, position);

            MinInitialSpeed = 0.0f;
            MaxInitialSpeed = 9.0f;
            MinInitialSize = 400;
            MaxInitialSize = 600;
            MinLifeTimeMs = 400;
            MaxLifeTimeMs = 500;

            color = Color.White;
        }

        protected override void InitParticle(int index, Vector3 position, float initialTimeMsOffset)
        {
            base.InitParticle(index, Vector3.Zero, initialTimeMsOffset);
            vertices[index].InitialPosition = position;
            float speed = RandomHelper.RandomBetween(MinInitialSpeed, MaxInitialSpeed);
            vertices[index].InitialVelocity =
                Vector3.TransformNormal(new Vector3(0, 0, 1), rotation) * speed + this.velocity;
        }
    }
}
